import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

const routes = [
  { path: '/login', component: () => import('@/views/Login') },
  { path: '/detail/:id', component: () => import('@/views/Detail') },
  { path: '/register', component: () => import('@/views/Register') },
  {
    path: '/',
    component: () => import('@/views/Mobile.vue'),
    redirect: '/login',
    children: [
      {
        path: 'home',
        component: () => import('@/views/Layout/Home.vue')
      },
      {
        path: 'classify',
        component: () => import('@/views/Layout/Classify.vue')
      },
      {
        path: 'release',
        component: () => import('@/views/Layout/Release.vue')
      },
      { path: 'user', component: () => import('@/views/Layout/User.vue') }
    ]
  },
  { path: '/userinfo/:id', component: () => import('@/views/UserInfo.vue') },
  { path: '/classifyList', component: () => import('@/views/ClassifyList.vue') },
  { path: '/myArticle', component: () => import('@/views/MyArticle.vue') }
]

const router = new VueRouter({
  routes
})

// router.beforeEach((to, form, next) => {
//   if (to.path === '/login' || to.path === '/register') {
//     next()
//   } else {
//     next('/login')
//   }
// })
export default router
